﻿Imports DTO
Imports System.Data.Linq

Public Class ChiTietMuonTraDao
    Public Shared Function LayBang() As Table(Of ChiTietMuonTra)
        Dim db As New ThuVienDataContext()
        Return db.ChiTietMuonTras
    End Function

    Public Shared Function LayDanhSach() As IEnumerable(Of ChiTietMuonTra)
        Dim lst As IEnumerable(Of ChiTietMuonTra)
        Dim db As New ThuVienDataContext()
        lst = From ctt In db.ChiTietMuonTras Select ctt
        Return lst
    End Function

    Public Shared Function LayChiTiet(ByVal mpm As Integer) As ChiTietMuonTra
        Dim db As New ThuVienDataContext()
        Dim ct As ChiTietMuonTra
        ct = (From c In db.ChiTietMuonTras Where c.MPM = mpm Select c).Single
        Return ct
    End Function

    Public Shared Sub Them(ByVal t As ChiTietMuonTra)
        Dim db As New ThuVienDataContext()
        db.ChiTietMuonTras.InsertOnSubmit(t)
    End Sub

    Public Shared Sub Capnhat(ByVal ct As ChiTietMuonTra)
        Dim db As New ThuVienDataContext()
        Dim chitiet = (From t In db.ChiTietMuonTras Where t.MCTMT = ct.MCTMT Select t).Single
        chitiet.MPT = ct.MPT
        db.SubmitChanges()
    End Sub
End Class